/*******************************************************************************
 * Copyright (c) 2006 CEA List.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     CEA List - initial API and implementation
 *******************************************************************************/
package com.cea.papyrus.core.ui.dialogs;

import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;

import com.cea.papyrus.core.PapyrusPlugin;
import com.cea.papyrus.core.utils.Debug;

/**
 * 
 * 
 * @author Patrick Tessier
 * @since 28 juil. 06
 * 
 * this class is used to display an error message
 */

public class PapyrusMessageDialog {

	/**
	 * 
	 * 
	 * @param message ot the error
	 * @param e the exception that launch it
	 */
	public static void display(String message, Exception e){
		if (e!=null){
			ErrorDialog.openError(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
				"Papyrus Error Message",
				message,

				new Status(IStatus.ERROR,
						PapyrusPlugin.PLUGIN_ID, IStatus.OK,
						IDEWorkbenchMessages.InternalError, e));
			Debug.log(e);
		}
		else{
			MessageDialog.openInformation(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
					"Papyrus Info Message",
					message);
			Debug.log(IStatus.ERROR, message);
		}
	}
}
